CC = gcc
CFLAGS = -std=c99 -Wall -pedantic-errors -Werror $(DEBUG)
DEBUG = -DNDEBUG
COMPILE = $(CC) -c $(CFLAGS) -o $@ $<
LINK = $(CC) $^ -o $@ -L. -lmtm
TESTS = dish_test chef_test judge_test tournament_test
EXEC = mtm_game $(TESTS)

mtm_game: main.o parse.o dish.o chef.o judge.o tournament.o
	$(LINK)

tests: $(TESTS)

all: mtm_game tests

dish_test: dish_test.o dish.o
	$(LINK)

chef_test: chef_test.o dish.o chef.o
	$(LINK)		
		
judge_test: judge_test.o dish.o chef.o judge.o
	$(LINK)
        
tournament_test: tournament_test.o dish.o chef.o judge.o tournament.o
	$(LINK)
	
clean:
	rm -fr *.o $(EXEC)

debug: DEBUG = -DDEBUG -g -Wextra
debug: all

dish.o: dish.c dish.h
	$(COMPILE)
chef.o: chef.c dish.h chef.h
	$(COMPILE)
judge.o: judge.c dish.h chef.h judge.h
	$(COMPILE)
tournament.o: tournament.c tournament.h chef.h dish.h judge.h
	$(COMPILE)
main.o: main.c mtm_wet3.h parse.h tournament.h chef.h dish.h judge.h
	$(COMPILE)
parse.o: parse.c mtm_wet3.h parse.h tournament.h chef.h dish.h judge.h
	$(COMPILE)
dish_test.o: tests/dish_test.c dish.h
	$(COMPILE)
chef_test.o: tests/chef_test.c dish.h chef.h
	$(COMPILE)
judge_test.o: tests/judge_test.c dish.h chef.h judge.h
	$(COMPILE)
tournament_test.o: tests/tournament_test.c tournament.h chef.h dish.h judge.h
	$(COMPILE)